import request from '../utils/request'

// 获取文章详情
const getAticleDetailAPI = ({ artId }) => request({
  method: 'GET',
  url: `/v1_0/articles/${artId}`
})

// 关注作者
const followAutAPI = ({ autId }) => request({
  method: 'POST',
  url: '/v1_0/user/followings',
  data: {
    target: autId
  }
})

// 取关作者
const unFollowAutAPI = ({ autId }) => request({
  method: 'DELETE',
  url: `/v1_0/user/followings/${autId}`,
  data: {
    target: autId
  }
})

// 喜欢
const likeArtAPI = ({ artId }) => request({
  method: 'POST',
  url: '/v1_0/article/likings',
  data: {
    target: artId
  }
})
// 不喜欢
const disLikeArtAPI = ({ artId }) => request({
  method: 'DELETE',
  url: `/v1_0/article/likings/${artId}`
})

// 文章评论
const getArtCommentAPI = ({ artId, offset }) => request({
  method: 'GET',
  url: '/v1_0/comments',
  params: {
    type: 'a',
    source: artId,
    offset,
    limit: 10
  }
})

// 点赞
const likeCmtAPI = ({ comId }) => request({
  method: 'POST',
  url: '/v1_0/comment/likings',
  data: {
    target: comId
  }
})

// 取消点赞
const disLikeCmtAPI = ({ comId }) => request({
  method: 'DELETE',
  url: `/v1_0/comment/likings/${comId}`,
  data: {
    target: comId
  }
})

// 发布评论
const pubCmtAPI = ({ artId, data }) => request({
  method: 'POST',
  url: '/v1_0/comments',
  data: {
    target: artId,
    content: data
  }
})

// 上拉加载更多

export {
  getAticleDetailAPI,
  followAutAPI,
  unFollowAutAPI,
  likeArtAPI,
  disLikeArtAPI,
  getArtCommentAPI,
  likeCmtAPI,
  disLikeCmtAPI,
  pubCmtAPI
}
